Skip to content

Conversation

@felixbarny
Copy link
Member

Optimized parsing for date and date_nanos if the data is provided as epoch millis.

@felixbarny felixbarny added >non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types :StorageEngine/Mapping The storage related side of mappings labels Aug 5, 2025
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team Team:StorageEngine v9.2.0 Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch labels Aug 5, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I didn't realize dates were provided as number instead of string when indexing via OTLP.

felixbarny added a commit to felixbarny/opentelemetry-collector-contrib that referenced this pull request Aug 6, 2025
… as a number

This improves the ingestion performance in Elasticsearch as it can leverage an optimized code path for date parsing.

See elastic/elasticsearch#132462

This is not a breaking change because we are using the `date` field type for metrics. Supporting a more granular date format, such as `date_nanos` doesn't seem sensible for metrics as it would cause a big storage overhead. Most other metrics data stores also don't support more granularity than milliseconds.
@felixbarny
Copy link
Member Author

Well, today, the Elasticsearch exporter in the OTel collector sets an epoch millis timestamp with a fractional for the @timestamp field. However, this is formatted as a string, as a double/float64 can't properly represent recent timestamps with nanosecond precision fractionals. So today it would look like "1721314113467.654123".

But for metrics in particular, I don't think this level of granularity is useful and we're using the date field type anyway, which only uses millisecond granularity. Therefore, I've created a PR for the ES exporter to use a simple numeric epoch millis timestamp for metrics: open-telemetry/opentelemetry-collector-contrib#41811.

atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Aug 6, 2025
… as a number (#41811)

This improves the ingestion performance in Elasticsearch as it can
leverage an optimized code path for date parsing.

See elastic/elasticsearch#132462

This is not a breaking change because we are using the `date` field type
for metrics. Supporting a more granular date format, such as
`date_nanos` doesn't seem sensible for metrics as it would cause a big
storage overhead. Most other metrics data stores also don't support more
granularity than milliseconds.

---------

Co-authored-by: Carson Ip <[email protected]>
@felixbarny felixbarny merged commit a684ef9 into elastic:main Aug 8, 2025
33 checks passed
@felixbarny felixbarny deleted the date-parsing-optimization branch August 8, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types :StorageEngine/Mapping The storage related side of mappings Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch Team:StorageEngine v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants